package com.lyn.seckill.validator;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class ValidationResult {
    // 校验结果是否有错
    private boolean hasError;
    // 存放错误信息的Map
    private Map<String,String> errorMessageMap = new HashMap<>();

    // 实现通用的格式化字符串信息获取错误结果的方法
    public String getErrorMessage() {
        return StringUtils.join(errorMessageMap.values().toArray(),",");
    }

    public boolean isHasError() {
        return hasError;
    }

    public void setHasError(boolean hasError) {
        this.hasError = hasError;
    }

    public Map<String, String> getErrorMessageMap() {
        return errorMessageMap;
    }

    public void setErrorMessageMap(Map<String, String> errorMessageMap) {
        this.errorMessageMap = errorMessageMap;
    }
}
